#!/usr/bin/node

const log = console.log;

function Bomb(id){
  const _id = id;
  let timeId;

  //启动
  this.start = () => {
    log('It will bomb after 3s');
    timeId = setTimeout(()=>{
      log(`Bomb!${_id}`);
    },3000);
  };

  //关闭
  this.clear = () =>{
    clearTimeout(timeId);
  };}

const b1 = new Bomb(1);
b1.start();
const b2 = new Bomb(2);
b2.start();

setTimeout(b2.clear,1000);
